# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990

# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://stackoverflow.com/a/13714219/6328514
# https://stackoverflow.com/questions/36711392/cmake-how-to-use-if-condition-in-add-custom-command

# https://blog.csdn.net/gubenpeiyuan/article/details/51096777


cmake_minimum_required (VERSION 3.0)
project(hello)

set(PREFIX_DIR ${CMAKE_CURRENT_BINARY_DIR}/_prefix)
set(INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/_install)
set(INCLUDE_DIR ${INSTALL_DIR}/include)
set(LIBRARY_DIR ${INSTALL_DIR}/lib)

include(ExternalProject)
ExternalProject_Add(librdkafka
    PREFIX ${PREFIX_DIR}/librdkafka
    GIT_REPOSITORY https://github.com/edenhill/librdkafka.git
    GIT_TAG "v0.11.6"
    # https://gitlab.kitware.com/cmake/cmake/issues/16419
    # stop rebuild every time
    UPDATE_COMMAND ""
    CONFIGURE_COMMAND COMMAND <SOURCE_DIR>/configure --prefix=${INSTALL_DIR}
    BUILD_IN_SOURCE 1
)

#include (custom-target)

add_subdirectory(src)
add_subdirectory(util)

